package com.myBlog.config;

import com.myBlog.intercaptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class IntercaptorList implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        @Hide: 屏蔽jwt登录和相关拦截
//        registry.addInterceptor(new JWTInterceptor())
//                //拦截的路径
//                .addPathPatterns("/**")
//                //排除登录接口
//                .excludePathPatterns("/user/jwtLogin");

        registry.addInterceptor(this.getLoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/user/**")
                .excludePathPatterns("/test/**").excludePathPatterns("/media/**").excludePathPatterns("/static/**");
    }

    @Bean
    public HandlerInterceptor getLoginInterceptor(){
        return  new LoginInterceptor();
    }
}
